﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using IHISCETeim.Library;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using IHISCETeim.Model;
namespace IHISCETeim.DAL
{
    public class UOneMonthAlarmDAL
    {
        public static DataTable GetPagination(string AlarmDate, int PageIndex, int PageSize, string Sort, ref int TotalCount)
        {
            Database DB = DatabaseFactory.CreateDatabase();

            DbCommand dbCommand = DB.GetStoredProcCommand("UOneMonthAlarm_GetPagination");

            DB.AddInParameter(dbCommand, "AlarmDate", DbType.String, AlarmDate);
            DB.AddInParameter(dbCommand, "PageIndex", DbType.Int32, PageIndex);
            DB.AddInParameter(dbCommand, "PageSize", DbType.Int32, PageSize);
            DB.AddInParameter(dbCommand, "Sort", DbType.String, Sort);
            DB.AddOutParameter(dbCommand, "TotalCount", DbType.Int32, 8);
            DataTable dt = DB.ExecuteDataSet(dbCommand).Tables[0];

            TotalCount = Convert.ToInt32(DB.GetParameterValue(dbCommand, "TotalCount"));
            return dt;
        }
        /// <summary>
        /// 更改为已回访
        /// </summary>
        /// <param name="UWCID"></param>
        /// <param name="VisitType"></param>
        /// <returns></returns>
        public static bool UpdateState(int UWCID, String VisitType)
        {
            try
            {
                Database DB = DatabaseFactory.CreateDatabase();

                DbCommand dbCommand = DB.GetStoredProcCommand("UOneMonthAlarm_UpdateState", UWCID, VisitType);
                DB.ExecuteNonQuery(dbCommand);
                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}
